package com.xinxing.learning.batch.mybatisplus.step;

import com.xinxing.learning.batch.entity.User;
import com.xinxing.learning.batch.mapper.target.TargetUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Slf4j
public class UserItemWriter implements ItemWriter<User> {

    @Autowired
    private TargetUserMapper targetUserMapper;

    @Override
    public void write(List<? extends User> list) throws Exception {
        for (User user : list) {
            targetUserMapper.insert(user);
        }
    }
}
